$(function () {
    findAll();
});

function findAll() {
    $.ajax({
        url: '/product/product',
        data: '',
        type: 'get',
        dataType: 'json',
        success: function (data) {
            console.log(data.data.ProductModle,"00000000");
            setProductData(data.data.ProductModle);

        }
    })
}

function setProductData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {

        html +='<div onclick="changeProduct('+data[i].id+')">\n' +
            '                    <div><img src="'+data[i].imgHref+'" height="240" width="180"/></div>\n' +
            '                    <div>'+data[i].name+'</div>\n' +
            '                    <div>价格：'+data[i].normalPrice+'</div>\n' +
            '                </div>';

    }
    $("#product").html(html);
}
function changeProduct(id){
    sessionStorage.setItem("id",id);
    location.href = '/front/html/productPage.html';
}
